﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.Globalization;

namespace HCQ2_Model.VRQDMeta.InputDto._20220112
{
    /// <summary>
    ///   新增房间
    /// </summary>
    public class InputRoom
    {
        /// <summary>
        ///  用户编码
        /// </summary>
        [Required(ErrorMessage = "用户编码必传！")]
        public string userid { get; set; }
        /// <summary>
        ///  名称
        /// </summary>
        [Required(ErrorMessage = "名称必传！")]
        public string fileName { get; set; }
        /// <summary>
        ///  简介
        /// </summary>
        public string fileNote { get; set; }
        /// <summary>
        ///  最大人数
        /// </summary>
        [Required(ErrorMessage = "最大人数必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入最大人数")]
        public int playerNum { get; set; }
        /// <summary>
        ///  密码
        /// </summary>
        public string roomPwd { get; set; }
        /// <summary>
        ///  开始时间 格式：【yyyyMMddHHmmss】
        /// </summary>
        public string gameStart { get; set; }
        /// <summary>
        ///  结束时间 格式：【yyyyMMddHHmmss】
        /// </summary>
        public string gameEnd { get; set; } = "99991231000000";
        /// <summary>
        ///  房间id
        /// </summary>
        //[Required(ErrorMessage = "房间id必传！")]
        public string roomID { get; set; }
        /// <summary>
        ///  应用id
        /// </summary>
        [Required]
        public int appFileID { get; set; }
        /// <summary>
        ///  金额
        /// </summary>
        [Required(ErrorMessage = "金额必传！")]
        public decimal price { get; set; }
        /// <summary>
        /// 转T_DocumentInfo实体
        /// </summary>
        /// <returns></returns>
        public T_DocumentInfo ToEntity()
        {
            DateTime? dt = null;
            if (!string.IsNullOrEmpty(this.gameStart))
                dt = DateTime.ParseExact(this.gameStart, "yyyyMMddHHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None);
            return new T_DocumentInfo
            {
                file_name = this.fileName,
                file_note = this.fileNote,
                pag_num = this.playerNum,
                qr_code = this.roomPwd,
                attach_url = this.roomID,
                game_start = dt,
                game_end = DateTime.ParseExact(this.gameEnd, "yyyyMMddHHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None),
                file_money = this.price,
                file_classify = "",
                doc_type = ""
            };
        }
    }

    /// <summary>
    ///  编辑房间
    /// </summary>
    public class InputEditRoom: InputRoom
    {
        /// <summary>
        ///  房间商品id
        /// </summary>
        [Required(ErrorMessage = "房间商品id必传！")]
        [RegularExpression("^([1-9][0-9]*)$", ErrorMessage = "请正确输入商品id")]
        public int fileID { get; set; }
    }
}